﻿using AutoMapper;
using MediatR;
using S.EarTag.API.Application.MediatorCommand.BodyMeasureCommand;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Application.MediatorCommandHandler.BodyMeasureCommandHandler
{
    public class BodyMeasureUpdCommandHandler : IRequestHandler<BodyMeasureUpdCommand, bool>
    {
        private readonly IBodyMeasureModelRepository _bodyMeasureModelRepository;
        private readonly IMapper _mapper;
        public BodyMeasureUpdCommandHandler(IBodyMeasureModelRepository bodyMeasureModelRepository,IMapper mapper)
        {
            _bodyMeasureModelRepository = bodyMeasureModelRepository;
            _mapper = mapper;
        }
        /// <summary>
        /// 修改体尺测量数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<bool> Handle(BodyMeasureUpdCommand request, CancellationToken cancellationToken)
        {
            return await _bodyMeasureModelRepository.UpdateAsync(_mapper.Map<BodyMeasureModel>(request));
        }
    }
}
